from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/register.html')
# 1.获取元素的文本
txt = driver.find_element(By.CSS_SELECTOR, '#fw').text
print('元素文本：', txt)
# 2.获取元素大小
size = driver.find_element(By.CSS_SELECTOR, '#user').size
print('元素大小：', size['width'], size['height'])
# 3.获取元素的属性
password = driver.find_element(By.CSS_SELECTOR, '#password')
type = password.get_attribute('type')
p = password.get_attribute('placeholder')
print('type属性：', type, ' 提示信息：', p)
# 4.判断元素是否可见
display = driver.find_element(By.CSS_SELECTOR, 'span').is_displayed()
print('span元素是否可见：', display)
# 5.判断元素是否可用
enable = driver.find_element(By.CSS_SELECTOR, '#cancel').is_enabled()
print('按钮是否可用：', enable)
# 6.判断元素是否被选中
qc = driver.find_element(By.CSS_SELECTOR, '#qc')
# 点击选中
qc.click()
select = qc.is_selected()
print('是否被选中：', select)

sleep(3)
driver.quit()